home *** CD-ROM | disk | FTP | other *** search
/ Aminet 1 / Aminet - June 1993 [Walnut Creek].iso / usenet / sources / volume91 / devices / irc_1_0 / part01 next >
Encoding:
Internet Message Format  |  1991-03-22  |  50.7 KB

  1. From: amiga-request@ab20.larc.nasa.gov (Amiga Sources/Binaries Moderator)
  2. Newsgroups: comp.sources.amiga
  3. Subject: v91i069: IRC 1.0 - IR remote reader, Part01/05
  4. Message-ID: <comp.sources.amiga:v91i069@ab20.larc.nasa.gov>
  5. Date: 22 Mar 91 15:16:06 GMT
  6. Approved: tadguy@uunet.UU.NET (Tad Guy)
  7.  
  8. Submitted-by: ron@vicorp.uucp (Ron Peterson)
  9. Posting-number: Volume 91, Issue 069
  10. Archive-name: devices/irc-1.0/part01
  11.  
  12. [ includes uuencoded iff file.  the file IRMasterImage.h was split to
  13.   allow posting; combine all IRMI.h.?? files to IRMasterImage.h ...tad ]
  14.  
  15. This code is an uncompleted version of an IR remote controlled AREXX
  16. utility.  It is uncompleted because no one wants to pay me to finish
  17. it (great sadness...)  I have placed it in the public domain as an
  18. example of how to read an IR remote control signal using the parallel
  19. port.
  20.  
  21. The code runs as it is on an Amiga 1000 with 1.5M of RAM (I suspect it
  22. will run in 512K also) when compiled using Lattice's V5.04 C compiler
  23. and asm assembler.  I've only run it under V1.2 of the operating
  24. system so I don't know how it will work under V1.3 and higher.  I've
  25. pulled out all the AREXX specific code so that you don't have to have
  26. AREXX to compile or run it.  The file Schematic.ilbm contains a simple
  27. electronics schematic for hooking a Radio Shack IR receiver to the
  28. parallel port on an A1000.  NOTE that if you have an Amiga other than
  29. an A1000 you must change the +5Vdc and gnd connections and use a male
  30. connector instead of a female.  I think the connections for other
  31. machines is pin 14 = +5Vdc and pin 25 = gnd but don't trust my
  32. memory---verify it!
  33.  
  34. ron@vicorp.com or uunet!vicorp!ron
  35.  
  36. #!/bin/sh
  37. # This is a shell archive.  Remove anything before this line, then unpack
  38. # it by saving it into a file and typing "sh file".  To overwrite existing
  39. # files, type "sh file -c".  You can also feed this as standard input via
  40. # unshar, or by typing "sh <file", e.g..  If this archive is complete, you
  41. # will see the following message at the end:
  42. #        "End of archive 1 (of 5)."
  43. # Contents:  BackGround.c LetGo.asm Schematic.uu VERSION.h irc.c irc.h
  44. #   ircserver.asm linkirc readme tmp
  45. # Wrapped by tadguy@ab20 on Fri Mar 22 10:16:01 1991
  46. PATH=/bin:/usr/bin:/usr/ucb ; export PATH
  47. if test -f 'BackGround.c' -a "${1}" != "-c" ; then 
  48.   echo shar: Will not clobber existing file \"'BackGround.c'\"
  49. else
  50. echo shar: Extracting \"'BackGround.c'\" \(827 characters\)
  51. sed "s/^X//" >'BackGround.c' <<'END_OF_FILE'
  52. X/*----------------------- B a c k G r o u n d . c ----------------------*/
  53. X/* This routine draws the raised background for the user interface in   */
  54. X/* IRMaster.c.  It was put into a seperate module so that the Image     */
  55. X/* data could be seperated from the rest of the gadget, text, etc.      */
  56. X/* structures in order to be able to fit everything into the available  */
  57. X/* RAM space when compiling.                                            */
  58. X/*----------------------------------------------------------------------*/
  59. X
  60. X#include "irc.h"
  61. X#include "IRMasterImage.h"
  62. X
  63. Xextern struct RastPort *WRPort;
  64. X
  65. Xint BackGround()
  66. X{
  67. X   /*--- Draw raised background. */
  68. X
  69. X   DrawImage(WRPort, &Image53, (short)0, (short)0);
  70. X
  71. X   /*--- Draw border for help messages. */
  72. X
  73. X   DrawBorder(WRPort, &Border4, (short)0, (short)0);
  74. X
  75. X   return(0);
  76. X}
  77. END_OF_FILE
  78. if test 827 -ne `wc -c <'BackGround.c'`; then
  79.     echo shar: \"'BackGround.c'\" unpacked with wrong size!
  80. fi
  81. # end of 'BackGround.c'
  82. fi
  83. if test -f 'LetGo.asm' -a "${1}" != "-c" ; then 
  84.   echo shar: Will not clobber existing file \"'LetGo.asm'\"
  85. else
  86. echo shar: Extracting \"'LetGo.asm'\" \(1365 characters\)
  87. sed "s/^X//" >'LetGo.asm' <<'END_OF_FILE'
  88. X;
  89. X; LetGo.asm
  90. X;
  91. X; Reads from parallel port until detects a quiescent state.
  92. X;
  93. X        csect text
  94. X
  95. X    xdef _LetGo
  96. X
  97. X        xref _ciab
  98. X        xref _NSamples
  99. X
  100. X        xref _Forbid
  101. X        xref _Disable
  102. X        xref _Enable
  103. X        xref _Permit
  104. X
  105. Xdata1             equ   $bfe101
  106. Xdir1              equ   $bfe301
  107. X
  108. X_LetGo
  109. X;
  110. X; Save registers on stack.
  111. X;
  112. X         MOVEM.L A2-A6/D2-D7,-(SP)  ;  Push Registers 
  113. X;
  114. X; Set up parallel port for reading.
  115. X;
  116. X         move.b   #0,dir1           * all lines read
  117. X         move.b   #0,data1
  118. X;
  119. X; Read from parallel port until see no change for 10000 cycles.
  120. X;
  121. Xagain:  move.l   #$2710,_NSamples  ; Initialize the counter to BIG.
  122. X                                   ; FFF0 * .1397us/clock * 50 clocks = .5sec
  123. X        move.l   #0,d1             ; Zero the detection flag.
  124. X
  125. Xloop:   move.b   data1,d0          ; Move byte from parallel port to buffer.
  126. X        andi.b   #1,d0             ; Mask off bit of interest.
  127. X        bne      over
  128. X        addq.l   #$1,d1            ; Found a zero = still getting signal.
  129. Xover:   subq.l   #$1,_NSamples     ; Decrement counter.
  130. X        bne      loop              ; Loop if haven't done 10000 yet.
  131. X
  132. X        tst.l    d1                ; Still receiving signal?
  133. X        bne      again
  134. X;
  135. X; Clean up, restore registers and return.
  136. X;
  137. X        MOVEM.L (SP)+,A2-A6/D2-D7  ;  Pop Registers
  138. X        RTS
  139. X
  140. X        END
  141. END_OF_FILE
  142. if test 1365 -ne `wc -c <'LetGo.asm'`; then
  143.     echo shar: \"'LetGo.asm'\" unpacked with wrong size!
  144. fi
  145. # end of 'LetGo.asm'
  146. fi
  147. if test -f 'Schematic.uu' -a "${1}" != "-c" ; then 
  148.   echo shar: Will not clobber existing file \"'Schematic.uu'\"
  149. else
  150. echo shar: Extracting \"'Schematic.uu'\" \(6940 characters\)
  151. sed "s/^X//" >'Schematic.uu' <<'END_OF_FILE'
  152. Xbegin 666 Schematic.ilbm
  153. XM1D]230``$S1)3$)-0DU(1````!0"@`#(``````$``0````H+`H``R$--05``:
  154. XM```&````\/#P1%!05@```&@```````````%H```!0`#(``(`6@`)````"@``9
  155. XM``H````````````````````````````````````````````````````!``(`-
  156. XM`````````````````0`"``````````````````$``D-23D<````(```*J@`!M
  157. XM`0%#4DY'````"```"JH``0$!0U).1P````@```JJ``$``$-23D<````(```*.
  158. XMJ@`!``!#04U'````!```P`!"3T19```20K$`L0"Q`+$`L0"Q`+$`L0"Q`+$`S
  159. XML0"Q`+$`L0`&``/W`,``!_X``'#\``-P``#`_```!_X``.#[``C`P>'AX```O
  160. XM!_#]``!'^P`)<`'``,``P```P/H`_\$`P/T``@`"T_X```/^```P_```,/D`2
  161. XM!`,```&P_``)`>'#,S,P```#,/T``,/[``0P`,`!X/T``,#Y`/_`_0#_`$;#U
  162. XM8<'P`V'G8;,9YV'@`;'A\<';X`,9YV,Q\`&!YV`!X^`!X,-S<W````,!YV`!,
  163. XMX?-AYV`#,>&QX,`!XS'!V>&!\`,QXS`#&?[`_0#_`$;#L,,``[`SLW-8,[,PV
  164. XM`W,S`,,S,`-;,[-C``/#,[``,S`#,,/S\_````/#,[`#,,.S,[`#NS-S,,`#:
  165. XM,[C#,#`#``,S,S`#6/[`_0#_`$;#,,'@`S#S,S-8\S/P`S/QX,,S,`-;,S/!%
  166. XMX`&#,S``\S`#\,.SL[````,#,S`#,,,S\S`#6S,S\,`#\UC#,/`!X`,S,S`#-
  167. XM6/[`_0#_`$;#,,`P`S,S`S&S,P,``S,`,,'C,`&S,P-@,`&#,P`#,S`&&,,SF
  168. XM,S#```,#,P`#,-,S`P`#&S,S`,`&&QC!XS``,`'C,S`!L/[`_0!+``'G,>/@S
  169. XM!S'?@=FQWX'@`=GCX>8S,`&QYX<SX`/!YX`!VS`&&_'AX>#```>!YX`!X&<Q/
  170. XMYX`#&>'9X>`&&QGF,=@#X`#!X=@!L>'AX/T`[@`!`^#8``$#X/X``0.`]@"Q,
  171. XM`+$``0`'_``#0```!_L``$?^``,#]AAP_0``</X``'#Z``%`P/L``!SC``$`4
  172. XM`_P``\````/[``##_@`#PP88,/T``##^```P^@``P/H```SC`"4``V'C,>`!1
  173. XM\>`!XV'CX=G@`?-AX`##XS&QX`'CX;`!V^&P`>'CX_[A#/'!X^'P`'CX;`#,S
  174. XM?'CG``L``[`S,S``PS`#,[#^,Q,P`,.S,`/P,S-S,``S,W`#,S-P`_PS#3#`\
  175. XMPS,S```,S-P`S,#,YP`C``,P\S/P`,,P`P,P\S,S\`##,_``P#'C,P``\S,P]
  176. XM`S,S,`,#_C,.\P#`PS,QX``\S,P`S'C\YP`)``,S,>,``-,P`_XS%3'C``#39
  177. XM,P``PS'C,S`#,S,P`>,S,`/],P<#,-##,S`P`/[,`P#,#,#G`#4`!S'8P>``2
  178. XM8>`!YS';-C'@`&<QX``!X,'9X`';,=@&,S'8`>'C,S'AX&'AXS/@`';,=@!V&
  179. XM^'CG`/0``0/@\@`!`^#1`,,``#_^`/\.!@`.`#\```+\`,,`#!F````&!@`&N
  180. XM`!F```;\`,,`#1F/.P\&!@\&`!F/.P^`_0#[``G@``/C\`#Q^`/@^@``(-L`H
  181. XM#!\!G8&&!AF&`!\9G8;\`/L`"6```;&8`9F``;#Z``!@VP`,&`>9AX8&'X8`V
  182. XM&!F9AOP`_P`1\`&8\&#P`9F8`!GP`9@`\/'Q_O`"^/.PW0`-&!F8&88&&`8`,
  183. XM&!F8!H#]`/\`#A@!W!AAF`&9\?AP&`&8`?R9`YAAF=C=``0\#OP.S_X/!``\7
  184. XM#SP#_`#_``]X`:QX8?@!F9@`P!@!F`&!_ID$^8!AF9C+`!```9@!C9AA@`&Q&
  185. XMF`&9F`&P`?V9!8&8:9F`8,P`_P`8[`&,[/#P`^/P`?CP`^``\/&9F/#P,//`Q
  186. XM8,P`L0"Q`+T`_O\`P/D`O0`#@```0/D`O0`%@```0?!X^P"]``6```!`V,S[!
  187. XM`+T`!8>``$#,W/L`O0`%C,``0,S\^P"]``6`P`!`S.S[`+T`!8.``$#8S/L`6
  188. XMY```!]O_!88``$'P>/L`Y```!-L``XS``$#Y`.0```3;``./P`!`^0#D```$U
  189. XMVP`#@```0/D`Y```!-L``X```$#Y`.0```3;``.```!`^0#D```$VP`#@```;
  190. XM0/D`Y```!-L``X```$#Y`.0```3;``.```!`^0#D```$VP`#@```0/D`Y```:
  191. XM!-L``X```$#Y`.0```3;``.```!`^0#D```$VP`#@```0/D`Y```!-L``X``?
  192. XM`$#Y`.0```3;``.```!`^0#D```$VP`&@```0,'G,/P`Y``!'\#<``:#!X!!&
  193. XMXS,P_`#D``%_\-P`!H<,P$'F`V#\`.0``?_XW``&@PW`0S8#P/P`Y`#:_P:#=
  194. XM#\!#]@-@_`#D``'_^-P`!H,.P$8;,S#\`.0``7_PW``&@PS`1AGG,/P`Y``!2
  195. XM'\#<``./QX!`^0#D```$VP`#@```0/D`Y```!-L``X```$#Y`/L``!_Y__,`0
  196. XM``3;``.```!`^0#[``@0`PP``&```8'S```$VP`#@```0/D`^P`($`&8\9CX:
  197. XM``.!\P``!-L``X```$#Y`/L`"!`!F9F88``!@?,```3;``.```!`^0#[``@0S
  198. XM`/&9F&```8'S```$VP`#@```0/D`^P`($`#QF9AH``&!\_\`_-L``X```$#YV
  199. XM`/L`"!``8/#L,``!@<P``X```$#Y`/L``!#[``$'X<P``X```$#Y`/L``!#Z%
  200. XM```!S``#@```0/D`^P``$/H```',``.```!`^0#[``00``'[#/X```',``.`\
  201. XM``!`^0#[``@0`&&##````\',``.```!`^0#[``@0`&'QF```!F',``.```!`[
  202. XM^0#[``00`?@9F/X``&',``.```!`^0#[``@0`&`8\````</F_^<``X```$#Y@
  203. XM`/L`"!``89CP```#`><```'G``.```!`^0#[``@0``#P8```!F'G```!YP`#G
  204. XM@```0/D`^P``$/L``0?AYP```><``X```$#Y`/L``!#Z```!YP```><``X``+
  205. XM`$#Y`/L``!#Z```!YP```><``X```$#Y`/L``!#^```X_@```><```'G``.`<
  206. XM``!`^0#[```0_@`$&````\'G```!YP`#@```0/D`^P`($`#M\-@```9AYP``#
  207. XM`><``X```$#Y`/L`!!`!F9FX_@``8><```'G``.```!`^0#[``@0`9F9F```F
  208. XM`</8__4``X```$#Y`/L`!!``\9F8_@``8><```'T```!]0`#@```0/D`^P`(M
  209. XM$`,9F.P```9AYP```?0```'U``.```!`^0#[``(0`?#]``$#P><```'T```!"
  210. XM]0`#@```0/D`^P``$/H```'G```!]````?4``X```$#Y`/L``!#Z```!YP``R
  211. XM`?0```'U``.```!`^0#[```?^?_G```!]````?4`!H```$```'#\`-@```'T*
  212. XM```!]0#_AP2`0```,/P`V````?0```'U``:,S,!!V^&P_`#8```!]````?4`Y
  213. XM!H#`P$,S,W#\`-@```'T```!]?__@P2`0S,S,/P`V````><`!H8&`$'C,S#\-
  214. XM`-@```'G``:,S,!&,S'8_`#8```!YP`$C\_`0^#Z`/X``0/._0`'`\_!AF?C2
  215. XMS##I```!YP`#@```0/D`_@`!!F;]``<&9F.&9@9F8.D```'G``.```!`^0#^*
  216. XM``T'!L/.S<`,!F&&9\!CP.D```'G``.```!`^0#^``T#AV!G9F`,Y\&&8&'!F
  217. XM@.D```'G``.```!`^0#]``SF8>9F8`QF`89@8P/`Z0```><``X```$#Y`/X`3
  218. XM``;^9@4'P`9F`8;^9@!@Z0```><``X```$#Y`/X`#0/.8[\&``/O!^/CQ^PP@
  219. XMZ0```><``X```$#Y`/H```_@```!YP`#@```0/D`V````><``X```$#Y`-@`N
  220. XM``'G``.```!`^0#^``,'X`'`_0`&X`_````!@.H```'G``.```!`^0#^``,!0
  221. XM@`-@_0`"8`9@Y@```><``X```$#Y`/X`"@&'PP[#SL/#8`9C_L,#AF/.P.T`;
  222. XM``'G``6```!``_#[`/X`$0&&9X=@9V9FX`?&9F9AAF9G8.T```'G`/^'`H!`<
  223. XMP_H`_@`1`89C!F'F9^9@!L?F!^&&9^9@[0```><`!8S,P$##X/L`_@`0`89C&
  224. XM!@9F!@9@!F8&9@&#Q@;L```!Y_\%@,#`0_`P^P#^``H'YF>/`[\#P[`.,_[#A
  225. XM`L&#S]$`_X,#@$#`,/L`O0`%A@#`0,,P^P"]``6,S,!``>#[`+T``X_'@$#Y1
  226. XM`/T`$\_``.&```/.```.``/'X<`!@\?CU0`#@```0/D`_@`5`89@`&````9F/
  227. XM```&``9F8P`#AF9A@-8``X```$#Y`/X`%0,&8\-C@\`'!L/#QF``8&8``8!@_
  228. XM8,#6``.```!`^0#^`!(#!\!FX89@`X=@9F;``<#'Q^&!_L#6``.```!`^0#^N
  229. XM`!4#!L'F889@`.9AY@>``P&&8`&`88#`U@`#@```0/D`_@`'`89F9F&&8`;]`
  230. XM9@G`!F&&8`&&88&`U@`#@```0/D`_0`3SC.SL\/``\YCL\Y@!^&#P`?CP8/5T
  231. XM``.```!`^0"]``.```!`^0"]``.```!`^0"]``.```!`^0"]``.```!`^0"]=
  232. XM``.```!`^0"]``.```!`^0"]``.```!`^0"]``.```!`^0#^```_^```!_X`A
  233. XM``S\```<]@`%!`!P```$Y@`#@```0/D`_@``#/@```/X```,]@`%#``P```,%
  234. XMY@#^_P#`^0#^``(,`';^'O\S'AX^&P`S'QP^'8`>``P>/AV`/AYV=AXQ@!\S6
  235. XM-AX`'Q[;`/X``@P`._XS#CN[LS,W`#,P##,S``,`#/XS#@`S`SL[,S6`##,[V
  236. XM,P`,,]L`_@`4#``S/S`S-;6_,S,`,QX,,S,`#P`,_C,"`#,/_C,(-8`,,S,_!
  237. XM``PSVP#^`"8,`#`P,S,QL;`S,P`S`PPS'@`S``PS,QX`,S,P,#,;``TS,S``5
  238. XM#3/;`/X``C\`>/X>(#&QGC,=@!V^'C-C`!V`'AXS8P`S'?AX'AL`!AV>'@`&Z
  239. XM'ML`[@``/OL``#[,`+$`L0#^``D,```<``0```1P^P``#/T```[[``IP#```&
  240. XM!``<#`!P!-L`^P`&#``,```,,/8``!O[```P_@`&#``,```P#.P``0'\_@`&2
  241. XM<``!\?AX_/P`_@`,'!\>#!X?'@`?-AX`=OX>%APS'G8`&'8>,P`>,S8<'CX?/
  242. XM``P<';8?ZP``S/X`!C```-C,S,#\`/X`#`PP,PP###,`##LS`#O^,Q8,,S,[A
  243. XM`#P[,SN``SN[##,S#``,##,[#.L`"L!XS'@P>`#,S`SX_`#^`"8,'C,,#PP_&
  244. XM``PS/P`S/S`_##,_,P`8,S,U@`\ULPP_,PP`#`PS,PSK``KPS.X,,,P`S/@XQ
  245. XM#/P`_@`G#`,S##,-,``-,S``,#`S,`P>,#``&#`S,8`S,;,,,#,-``P,'C,-=
  246. XM#.P`"L#\UCPP_`#,S&`,_`#^``P>/AX>'88>``9S'@!X_1X6#!YX`#QX'C&`$
  247. XM';&>'AXS!@`>'F-S!@SL`/_`!<;,,,``V/[,_`#:```^Z@`+`>!XQG9X>`'Q9
  248. XM^/QX_`"Q`/X`!QYP#``<!P`'_@`!<!S\`!,<!P`,!`!P```$`'``!``,```,O
  249. XM!-H`_@`',S````P#``/^``$P#/P`#0P#``P,`#````P`,``,_0#_#-H`_@`E`
  250. XM.#8<'@P;'AL`'AXV#!X`,9XS#!L^&!\`-C-V'P`V,Q\`'!\^&!_K``,!\``0G
  251. XM]`#^`"4<.PPS##<S-P`S`SL,,P`ULS,,-S,`#``[,SL,`#LS#``,,#,`#.H`[
  252. XM`M@`,/0`_@`7!S,,/PPS/S,`,`\S##\`-;,S##,S``P`_C,*#``S,PP`#!XSU
  253. XM``SJ``7,`'S-N'CW`/X`_S,&##`,,S`S`/XS&0PP`!LS,PPS,P`-`#,S,`T`T
  254. XM,S,-``P#,P`-Z@`"S/PP_LSW`/X``1YS_AX@'9X=@!X=GAX>`!L>'9X=LP`&J
  255. XM`',=^`8`'AV&`!X^,P`&Z@`%S``PS,S\]P#!``78`#1X^,#W`,(`!@'P`!@P4
  256. XMP'CW`+X``>'@]@#T```._0`#<```!,<`]```&_T``S````S'`/X``#[^'O\?J
  257. XM$1YV,P`8'G8`'S8>=A\`=C,^']P``'C\```0^`#^`/TS_S`1`SLS`#PS.P`PC
  258. XM.S,[#``[,S,PW```S/P``##X`/X`#C,_,#\>'@\S,P`8,S,`'OXS`0P`_C,`[
  259. XM'MT`"0&`>/CX>'A\>=CZ`/X`&#,P,S`#`S,P'@`8,S```S,S,`T`,#,S`PS>K
  260. XM``$!@/S,`C#,[/H`_@``,_X>_SX2'?@,`#P>>``^<QYX!@!X';,^#-X``0&`\
  261. XM_LP$_,`PS,SZ`/8``#C-`/W,!,#,-,S`^@#!`/]X_\S_>`(8>>#Z`+$`L0"Q4
  262. X3`+$`L0"Q`+$`L0"Q`+$`L0"Q`,#,%
  263. X``
  264. Xend
  265. Xsize 4924
  266. END_OF_FILE
  267. if test 6940 -ne `wc -c <'Schematic.uu'`; then
  268.     echo shar: \"'Schematic.uu'\" unpacked with wrong size!
  269. fi
  270. # end of 'Schematic.uu'
  271. fi
  272. if test -f 'VERSION.h' -a "${1}" != "-c" ; then 
  273.   echo shar: Will not clobber existing file \"'VERSION.h'\"
  274. else
  275. echo shar: Extracting \"'VERSION.h'\" \(26 characters\)
  276. sed "s/^X//" >'VERSION.h' <<'END_OF_FILE'
  277. X
  278. X#define VERSION " V1.0"
  279. X
  280. END_OF_FILE
  281. if test 26 -ne `wc -c <'VERSION.h'`; then
  282.     echo shar: \"'VERSION.h'\" unpacked with wrong size!
  283. fi
  284. # end of 'VERSION.h'
  285. fi
  286. if test -f 'irc.c' -a "${1}" != "-c" ; then 
  287.   echo shar: Will not clobber existing file \"'irc.c'\"
  288. else
  289. echo shar: Extracting \"'irc.c'\" \(27153 characters\)
  290. sed "s/^X//" >'irc.c' <<'END_OF_FILE'
  291. X/*------------------------------- i r c . c  -------------------------------*/
  292. X/* Experimental interrupt handler.                                          */
  293. X/* This routine sets up a level 2 interrupt server that is triggered by the */
  294. X/* ACK pin of the parallel port going low.  The interrupt server then uses  */
  295. X/* Timer B in CIA-B to time reading in data from the parallel port.         */
  296. X/* The ACK and one data input pin on the parallel port are tied             */
  297. X/* together by the hardware I built.  Initially the ACK interrupt is        */
  298. X/* enabled and the software sits and waits for something to happen.         */
  299. X/*                                                                          */
  300. X/* NEED TO CHECK RESOURCES  ---- FREEMEM!!!!!!!!!!!!!!!!*/
  301. X/*--------------------------------------------------------------------------*/
  302. X/*--- Includes and Defines. */
  303. X
  304. X#include "irc.h"
  305. X#include "IRMaster.h"   /* Definitions of Screen, Window and gadgets. */
  306. X
  307. X/* DBG = 1 --> Turn on debug printf's, DBG = 0 --> Turn off debug printf's. */
  308. X#define DBG 1
  309. X/* Set DEBUG to 0 to comment out code related to opening screen and window.*/
  310. X#define DEBUG 1
  311. X
  312. X#define NOERROR 0
  313. X#define ERROR 1
  314. X/*--- NSAMPLES is the number of data samples to be read into buffer. */
  315. X#define NSAMPLES 3000
  316. X/*--- TOLERENCE is the number of samples difference that is tolerated in */
  317. X/*--- order to match two patterns. */
  318. X#define TOLERENCE 50
  319. X
  320. X/*--- External system variables. */
  321. X
  322. Xextern struct Custom custom;
  323. Xextern struct CIA ciab;
  324. X
  325. Xextern struct GfxBase *GfxBase;
  326. Xextern struct IntuitionBase *IntuitionBase;
  327. Xextern struct WBStartup *WBenchMsg;  /* For Workbench startup. */
  328. X
  329. X/**********************************************************/  
  330. X/***************** Timer B Interrupt code *****************/
  331. X/**********************************************************/  
  332. X/*
  333. X   Update Timer every TIME_SLICE microseconds.
  334. X   TIME_SLICE = 1.397 * (desired # of microseconds) [71 = 100us]
  335. X   71, 50 work.
  336. X*/
  337. X#define TIME_SLICE ((unsigned short)35)
  338. X
  339. X/* Defines to make the code more readable. */
  340. X
  341. X#define ciatlo        ciab.ciatblo
  342. X#define ciathi        ciab.ciatbhi
  343. X#define ciacr        ciab.ciacrb
  344. X#define ciaicr        ciab.ciaicr
  345. X
  346. Xint TimerSigBit = -1;   /* Allocated signal bit. */
  347. XULONG TimerSigMask;      /* TimerSigBit converted into a mask. */
  348. Xstatic struct Library *CIAResource = NULL;
  349. Xstruct Task *thisTask;
  350. X
  351. Xint NSamples;           /* Number of samples in buffer. */
  352. X
  353. Xint SetUpTimer()
  354. X{
  355. X   char temp;
  356. X   unsigned short micros;
  357. X
  358. X   /*--- Check to see if timer B in CIA-B is already in use. */
  359. X   /*--- If START bit is set timer is probably being used. */
  360. X
  361. X#if DBG
  362. X   printf("\n Timer B control register = %X",ciab.ciacrb);
  363. X#endif
  364. X   if(ciab.ciacrb & 0x01)
  365. X   {
  366. X      printf("\n Timer B is already allocated.  Proceding anyway.");
  367. X   }
  368. X
  369. X   /*--- Set latched value for timer to count down from. */
  370. X
  371. X   micros = TIME_SLICE;
  372. X#if DBG
  373. X   printf("\n Sampling interval = %d * 1.397 microseconds", micros);
  374. X#endif
  375. X   ciatlo = micros & 0xFF;
  376. X   ciathi = micros >> 8;
  377. X
  378. X   /*--- Get ID for this task so can send it a signal. */
  379. X
  380. X   thisTask = NULL;
  381. X   thisTask = FindTask(NULL);
  382. X   if(thisTask == NULL)
  383. X   {
  384. X      printf("\n Error - Can't find this task ID.");
  385. X      return(ERROR);
  386. X   }
  387. X
  388. X   /*--- Get a signal bit. */
  389. X
  390. X   if((TimerSigBit = AllocSignal(-1L)) == -1)
  391. X   {
  392. X      printf("\n Timer: AllocSignal failed.");
  393. X      StopTime();  /* Deallocate resources. */
  394. X      return(ERROR);
  395. X   }
  396. X   TimerSigMask = 1L << TimerSigBit;
  397. X
  398. X   /*--- Open the CIA resource. */
  399. X
  400. X   if((CIAResource = OpenResource(CIABNAME)) == NULL)
  401. X   {
  402. X      printf("\n Timer: Couldn't open %s.", CIABNAME);
  403. X      StopTime();  /* Deallocate resources. */
  404. X      return(ERROR);
  405. X   }
  406. X
  407. X   /*--- Interrupts have been enabled so may already */
  408. X   /*--- have an interrupt.  So do this... */
  409. X
  410. X   ciab.ciacrb &= ~CIACRBF_START;    /* stop timer */
  411. X
  412. X   temp = ciaicr;  /* Read IRC register to clear interrupt. */
  413. X
  414. X   SetSignal(0, TimerSigMask);    /* clear signal */
  415. X
  416. X#if DBG
  417. X   printf("\n About to set RUNMODE");
  418. X#endif
  419. X   ciacr &= ~CIACRBF_RUNMODE; /* Set it to reload upon underflow. */
  420. X   ciacr &= ~CIACRBF_PBON; /* Output line PB7 is left alone. */
  421. X   ciacr &= ~CIACRBF_INMODE0; /* Count clock pulses. */
  422. X   ciacr &= ~CIACRBF_INMODE1; /* Count clock pulses. */
  423. X
  424. X#if DBG
  425. X   printf("\n About to strobe LOAD");
  426. X#endif
  427. X   ciacr |= CIACRBF_LOAD; /* Strobe Load to latch in countdown value. */
  428. X
  429. X#if DBG
  430. X   printf("\n About to enable timer b interrupts");
  431. X#endif
  432. X   ciaicr = 0x7D;  /* Disable all other CIA-B interrupts. */
  433. X   ciaicr = CIAICRF_SETCLR|CIAICRF_TB;  /* Enable timer B interrupts. */
  434. X#if DBG
  435. X   printf("\n Enabled timer b interrupts");
  436. X#endif
  437. X
  438. X   return(NOERROR);
  439. X}
  440. X
  441. Xint StopTime()
  442. X{
  443. X   if(thisTask != NULL)
  444. X   {
  445. X      /*--- Disable timer B interrupts. */
  446. X
  447. X#if DBG
  448. X      printf("\n Stopping timer B.");
  449. X#endif
  450. X      ciaicr = CIAICRF_TB;
  451. X
  452. X      /*--- Halt timer. */
  453. X
  454. X      ciacr &= ~CIACRBF_START;
  455. X
  456. X      /*--- Free resources. */
  457. X
  458. X      if(TimerSigBit != -1)
  459. X      {
  460. X#if DBG
  461. X         printf("\n Freeing signal bit.");
  462. X#endif
  463. X         FreeSignal(TimerSigBit);
  464. X      }
  465. X   }
  466. X
  467. X   return(NOERROR);
  468. X}
  469. X
  470. X/**********************************************************/  
  471. X/***************** LEVEL 2 Interrupt code *****************/
  472. X/**********************************************************/  
  473. X
  474. Xextern void ircserver();
  475. Xstruct Interrupt intrpt;
  476. X
  477. Xint AddINT2Server()
  478. X{
  479. X   /*--- init NODE structure */
  480. X
  481. X   intrpt.is_Node.ln_Type = NT_INTERRUPT;
  482. X   /* Was 0 but glasses flickered.  3 fixed it. */
  483. X   intrpt.is_Node.ln_Pri  = 127;
  484. X   intrpt.is_Node.ln_Name = "WWB";
  485. X   intrpt.is_Code        = ircserver;
  486. X   intrpt.is_Data        = NULL;
  487. X
  488. X#if DBG
  489. X   printf("\n About to add interrupt server...");
  490. X#endif
  491. X
  492. X   AddIntServer(INTB_PORTS, &intrpt);        /* Add server to chain */
  493. X
  494. X#if DBG
  495. X   printf("\n Added interrupt server.");
  496. X#endif
  497. X
  498. X   return(NOERROR);
  499. X}
  500. X
  501. X
  502. Xint RemoveServer()
  503. X{
  504. X   RemIntServer(INTB_PORTS, &intrpt);
  505. X
  506. X   return(NOERROR);
  507. X}
  508. X
  509. X
  510. X/**********************************************************/  
  511. X/************************** MAIN **************************/
  512. X/**********************************************************/  
  513. X
  514. Xunsigned char *buffer;  /* Pointer to storage for data to be read in. */
  515. Xunsigned char zuffer[NSAMPLES];  /* Storage for data to be read in. */
  516. Xunsigned char pattern[20][NSAMPLES];  /* Stored signal patterns. */
  517. Xchar *address, mask;
  518. X
  519. Xstruct Screen *Screen = NULL;
  520. Xstruct Window *Window = NULL;
  521. Xstruct RastPort *WRPort;
  522. Xstruct ViewPort *WVPort;
  523. X
  524. Xstruct IntuiMessage *message;
  525. XULONG class;
  526. XUSHORT code;
  527. Xstruct Gadget *igad;
  528. XUSHORT gadget_id;
  529. Xextern int BackGround();
  530. Xint helptxt();
  531. Xint IRButtonOff();                 /* Unhighlight button. */
  532. Xint IRButtonOn();                  /* Highlight button. */
  533. Xint IRButtonLabel();               /* Relabel button. */
  534. Xint GetPattern();                  /* Get signal pattern. */
  535. Xint DisplayPattern();              /* Draw the signal pattern. */
  536. Xint DPattern();                    /* Debug. */
  537. X
  538. X/*--- Buffers for area fill and text. */
  539. X
  540. XWORD chip areaArray[100];  /* Max of 20 vertices times 5 words per vertex. */
  541. Xstruct AreaInfo myAreaInfo;
  542. XPLANEPTR workspace;
  543. Xstruct TmpRas myTmpRas;
  544. X
  545. X#define NOTHING 0
  546. Xint active[21] =  /* Used to remember which buttons have patterns. */
  547. X{ 
  548. X   FALSE, FALSE, FALSE, FALSE, FALSE, FALSE, FALSE, FALSE, FALSE, FALSE, 
  549. X   FALSE, FALSE, FALSE, FALSE, FALSE, FALSE, FALSE, FALSE, FALSE, FALSE, 
  550. X   FALSE
  551. X};
  552. X
  553. X
  554. X
  555. X
  556. Xmain(argc, argv)
  557. Xint argc;
  558. Xchar **argv;
  559. X{
  560. X   int it, error, iz, is, try;
  561. X   int diff[4], match, smallest;
  562. X   BOOL exitflag;
  563. X   int mode;  /* Current mode of program (LEARN, NOTHING, etc. ) */
  564. X   int IRButtonSelected = -1;         /* Index of button currently selected. */
  565. X
  566. X   /*--- Ignore CTRL-C and CTRL-D. */
  567. X
  568. X   signal(SIGINT, SIG_IGN);
  569. X
  570. X   /*--- Open graphics and Intuition Libraries. */
  571. X
  572. X   GfxBase = NULL;
  573. X   GfxBase = (struct GfxBase *)OpenLibrary("graphics.library", 33);
  574. X   if(GfxBase == NULL)
  575. X   {
  576. X      printf("\n Error opening graphics library.");
  577. X      goto ShutDown;
  578. X   }
  579. X
  580. X   IntuitionBase = NULL;
  581. X   IntuitionBase = (struct IntuitionBase *)OpenLibrary("intuition.library", 33);
  582. X   if(IntuitionBase == NULL)
  583. X   {
  584. X      printf("\n Error opening Intuition library.");
  585. X      goto ShutDown;
  586. X   }
  587. X
  588. X   /*--- Open a new screen. */
  589. X
  590. X   Screen = (struct Screen *) OpenScreen(&NewScreenStructure); 
  591. X   if(Screen == 0L)
  592. X   {
  593. X      printf("\n Error opening a new screen.");
  594. X      goto ShutDown;
  595. X   }
  596. X
  597. X#if DEBUG
  598. X   /*--- Open window in screen. */
  599. X
  600. X   NewWindowStructure1.Screen = Screen;
  601. X   Window = (struct Window *) OpenWindow(&NewWindowStructure1);
  602. X   if(Window == 0L)
  603. X   {
  604. X      printf("\nError opening a new window");
  605. X      goto ShutDown;
  606. X   }
  607. X
  608. X   /*--- Get pointers to window structures. */
  609. X
  610. X   WRPort = Window->RPort;   /* Get pointer to windows' RastPort. */
  611. X   WVPort = (struct ViewPort *)ViewPortAddress(Window); /* Get pointer to window viewport. */
  612. X
  613. X   /*--- Set up area fill and text work buffers. */
  614. X
  615. X   InitArea(&myAreaInfo, &areaArray[0], 20);
  616. X   WRPort->AreaInfo = &myAreaInfo;
  617. X
  618. X   workspace = AllocRaster(640, 200);
  619. X   if(workspace == 0)
  620. X   {
  621. X      printf("\n Error - No space for temporary raster.");
  622. X      goto ShutDown;
  623. X   } else
  624. X   {
  625. X      InitTmpRas(&myTmpRas, workspace, RASSIZE(640,200));
  626. X      WRPort->TmpRas = &myTmpRas;
  627. X   }
  628. X
  629. X   /*--- Set color map. */
  630. X
  631. X   LoadRGB4(WVPort, Palette, (SHORT)16);
  632. X
  633. X   /*--- Draw raised background areas. */
  634. X
  635. X   BackGround();
  636. X
  637. X   /*--- Redraw the gadgets on top of the raised background. */
  638. X
  639. X   RefreshGadgets(&ARexx, Window, 0);
  640. X#endif /*DEBUG*/
  641. X
  642. X   /*--- Allocate the parallel port resource so that other tasks know it  */
  643. X   /*--- is taken. (This might not be a good idea.  Online! allocates the */
  644. X   /*--- the parallel port and this prevents me from doing                */
  645. X   /*--- "copy file to par:" in a seperate window.  So leave it out for   */
  646. X   /*--- now.  User will know if one program walks over another.          */
  647. X
  648. X   /*****************
  649. X   MR_ALLOCMISCRESOURCE(MR_PARALLELPORT, "IRMaster");
  650. X   MR_ALLOCMISCRESOURCE(MR_PARALLELBITS, "IRMaster");
  651. X   *****************/
  652. X
  653. X   /*--- Set up pointer to data buffer for SoftHandler(). */
  654. X   /*--- Assembler doesn't seem to recognize zuffer but DOES buffer. */
  655. X
  656. X   buffer = &zuffer[0];
  657. X#if DBG
  658. X   printf("\n buffer = %X", buffer);
  659. X#endif
  660. X
  661. X   /*--- Set up all the interrupt servers. */
  662. X
  663. X   AddINT2Server();
  664. X
  665. X   error = SetUpTimer();
  666. X   if(error)goto Fini;
  667. X
  668. X   /*--- Explicitly enable level6 and level2 interrupts (even though */
  669. X   /*--- they already seem to be enabled by default).                */
  670. X
  671. X/********* Causes sometimes guru.
  672. X   Disable();
  673. X   custom.intena |= INTF_SETCLR | INTF_EXTER;
  674. X   custom.intena |= INTF_SETCLR | INTF_SOFTINT;
  675. X   Enable();
  676. X*********/
  677. X
  678. X#if DBG
  679. X   /* This is slightly dangerous since it might clear any pending interrupts. */
  680. X   /*printf("\n Enabled interrupts are: %X", custom.intenar);*/
  681. X#endif
  682. X
  683. X   /*--- Set address for IRC register (used in GetSample.) */
  684. X
  685. X   address = (char *)0xBFED01;/* Address of the Interrupt Control Register in 8520-A */
  686. X
  687. X   /*--- MAIN PROGRAM LOOP. */
  688. X   /*--- Get messages from window until user presses CloseWindow gadget. */
  689. X
  690. X#if DEBUG
  691. X   exitflag = FALSE;
  692. X   mode = NOTHING;
  693. X   while(exitflag == FALSE)
  694. X   {
  695. X      /*--- If in DOIT mode wait for IR input. */
  696. X      if(mode == DOIT)
  697. X      {
  698. X         /*--- Wait for user to press a button. */
  699. X
  700. X         GetSample();
  701. X
  702. X         /*--- Match input to stored samples. */
  703. X
  704. X         match = find_match();
  705. X      }
  706. X
  707. X      /*--- Check for user action. */
  708. X
  709. X      message = (struct IntuiMessage *)GetMsg(Window->UserPort);
  710. X      if(message != 0)
  711. X      {
  712. X         class = message->Class;
  713. X         code = message->Code;
  714. X         igad = (struct Gadget *)message->IAddress;/*get pointer to gadget */
  715. X         ReplyMsg((struct Message *)message);
  716. X
  717. X         if(class == GADGETUP)
  718. X         {
  719. X            gadget_id = igad->GadgetID;   /* get my gadget code */
  720. X            switch(gadget_id)
  721. X            {
  722. X               case COMMANDSTR3:
  723. X#if DBG
  724. X                  printf("COMMANDSTR3\n");
  725. X#endif
  726. X                  break;
  727. X
  728. X               case COMMANDSTR1:
  729. X#if DBG
  730. X                  printf("COMMANDSTR1 = %s\n", commandstr1SIBuff);
  731. X#endif
  732. X                  /*--- Change the label on the button. */
  733. X
  734. X                  IRButtonLabel(commandstr1SIBuff, IRButtonSelected);
  735. X
  736. X                  /*--- Prompt user for next action. */
  737. X
  738. X                  helptxt("Now press the button on your handheld IR remote control",
  739. X                     "that you want memorized.");
  740. X
  741. X                  /*--- Get verified signal sample from the IR receiver. */
  742. X
  743. X                  GetPattern(IRButtonSelected);
  744. X
  745. X                  /*--- Remember which buttons have patterns stored. */
  746. X
  747. X                  active[IRButtonSelected] = TRUE;
  748. X
  749. X                  /*--- Unhighlight the control button. */
  750. X
  751. X                  IRButtonOff(&IRButtonSelected);
  752. X                  mode = NOTHING;
  753. X
  754. X                  break;
  755. X
  756. X               case COMMANDSTR2:
  757. X#if DBG
  758. X                  printf("COMMANDSTR2\n");
  759. X#endif
  760. X                  break;
  761. X
  762. X              default:
  763. X                  break;
  764. X            } /* switch(gadget_id) */
  765. X         } /* if(GADGETUP) */
  766. X
  767. X         if(class == GADGETDOWN)
  768. X         {
  769. X            gadget_id = igad->GadgetID;   /* get my gadget code */
  770. X            switch(gadget_id)
  771. X            {
  772. X               case EXIT:
  773. X#if DBG
  774. X                  printf("EXIT\n");
  775. X#endif
  776. X                  goto Fini;
  777. X                  break;
  778. X
  779. X               case AUTHOR:
  780. X#if DBG
  781. X                  printf("AUTHOR\n");
  782. X#endif
  783. X                  break;
  784. X
  785. X               case DOIT:
  786. X#if DBG
  787. X                  printf("DOIT\n");
  788. X#endif
  789. X                  mode = DOIT;
  790. X                  break;
  791. X
  792. X               case GETSET:
  793. X#if DBG
  794. X                  printf("GETSET\n");
  795. X#endif
  796. X                  break;
  797. X
  798. X               case SAVESET:
  799. X#if DBG
  800. X                  printf("SAVESET\n");
  801. X#endif
  802. X                  break;
  803. X
  804. X               case LEARN:
  805. X#if DBG
  806. X                  printf("LEARN\n");
  807. X#endif
  808. X                  helptxt("Press one of the twenty control buttons above.","");
  809. X                  mode = LEARN;
  810. X                  break;
  811. X
  812. X               case AREXX:
  813. X#if DBG
  814. X                  printf("AREXX\n");
  815. X#endif
  816. X                  break;
  817. X
  818. X               case IR20:
  819. X               case IR19:
  820. X               case IR18:
  821. X               case IR17:
  822. X               case IR16:
  823. X               case IR15:
  824. X               case IR14:
  825. X               case IR13:
  826. X               case IR12:
  827. X               case IR11:
  828. X               case IR10:
  829. X               case IR9:
  830. X               case IR8:
  831. X               case IR7:
  832. X               case IR6:
  833. X               case IR5:
  834. X               case IR4:
  835. X               case IR3:
  836. X               case IR2:
  837. X               case IR1:
  838. X                  /*--- Unhighlight any currently selected button. */
  839. X
  840. X                  IRButtonOff(&IRButtonSelected);
  841. X
  842. X                  /*--- Set current button to highlight and highlight it. */
  843. X
  844. X                  IRButtonSelected = (gadget_id - IR1) + 1;
  845. X
  846. X                  IRButtonOn(IRButtonSelected);
  847. X#if DBG
  848. X                  printf("IR-%d\n", (gadget_id - IR1) + 1);
  849. X#endif
  850. X                  if(mode == LEARN)
  851. X                  {
  852. X                     /*--- Prompt user. */
  853. X
  854. X                     helptxt("Enter the label name for the control button,",
  855. X                        "then press RETURN.");
  856. X                  } else
  857. X                  {
  858. X                     helptxt("Please choose a function button first.", "");
  859. X                  }
  860. X                  break;
  861. X
  862. X
  863. X               default:
  864. X                  mode = NOTHING;
  865. X                  printf("Error - Got a hit on an unknown gadget\n");
  866. X                  printf(" Gadget id was: hex: %X  decimal: %d\n", gadget_id,
  867. X                     gadget_id);
  868. X                  break;
  869. X            } /* switch(gadget_id) */
  870. X         } /* if(message) */
  871. X      } /* if(class...) */
  872. X   } /* while(GetMsg) */
  873. X#endif /*DEBUG*/
  874. X
  875. X
  876. X#if DBG
  877. X   printf("\n Timer B control register = %X",ciab.ciacrb);
  878. X   printf("\n buffer = %X", buffer);
  879. X#endif
  880. X
  881. X   /*--- Shut down timer B */
  882. X
  883. XFini:
  884. X   StopTime();
  885. X
  886. X   /*--- Turn off the 8520's recognition of the ACK as an interrupt. */
  887. X
  888. X   mask = 0x10; /* Hex 10 = 00010000 Should disable the 8520 FLAG interrupt. */
  889. X   *address = mask;  /* Disable the interrupt. */
  890. X
  891. X   /*--- Remove the level2 interrupt server from server chain. */
  892. X
  893. X   RemoveServer();
  894. X
  895. X   /*--- Exit cleanly. */
  896. X
  897. XShutDown:
  898. X
  899. X   /*--- Deallocate parallel port resource. Commented out for reasons above. */
  900. X
  901. X   /*****************
  902. X   MR_FREEMISCRESOURCE(MR_PARALLELPORT);
  903. X   MR_FREEMISCRESOURCE(MR_PARALLELBITS);
  904. X   *****************/
  905. X
  906. X   /*--- Close window and screen. */
  907. X
  908. X#if DEBUG
  909. X   if(Window)CloseWindow(Window);
  910. X   if(Screen)CloseScreen(Screen);
  911. X#endif /*DEBUG*/
  912. X
  913. X   /*--- Close libraries. */
  914. X
  915. X   if(GfxBase)CloseLibrary((struct Library *)GfxBase);
  916. X   if(IntuitionBase)CloseLibrary((struct Library *)IntuitionBase);
  917. X
  918. X   /*--- Free allocated memory. */
  919. X#if DEBUG
  920. X   if(workspace != 0)FreeRaster(workspace, 640, 200);
  921. X#endif /*DEBUG*/
  922. X
  923. X   return(0);  /* To keep compiler happy. */
  924. X} /* End of main(). */
  925. X
  926. X
  927. X
  928. Xint GetSample()
  929. X{
  930. X   int idx;
  931. X
  932. X   /*--- Set up for taking another sample. */
  933. X
  934. X#if DBG
  935. X   printf("\n Setting up for next sample.");
  936. X#endif
  937. X   for(idx=0; idx<NSAMPLES; idx++)zuffer[idx] = 0; /* Zero the buffer. */
  938. X   NSamples = NSAMPLES;  /* Reset sample counter. */
  939. X   buffer = &zuffer[0];  /* Reset pointer to start of buffer. */
  940. X
  941. X   ciacr |= CIACRBF_LOAD; /* Strobe Load to latch in countdown value. */
  942. X   ciaicr = CIAICRF_SETCLR|CIAICRF_TB;  /* Enable timer B interrupts. */
  943. X   mask = *address;  /* Clear any pending interrupts. */
  944. X   mask = 0x90;  /* Hex 90 = 10010000 Should enable the 8520 FLAG interrupt. */
  945. X   *address = mask;  /* Enable the ACK interrupt. */
  946. X
  947. X   /*--- Interrupts are now all armed and dangerous.  */
  948. X   /*--- Wait until data is ready. */
  949. X
  950. X#if DBG
  951. X   printf("\n Waiting...press a button.");
  952. X#endif
  953. X   Wait(TimerSigMask);  /* Wait for full buffer. */
  954. X
  955. X   /*--- Stop timer B from counting. */
  956. X
  957. X#if DBG
  958. X   printf("\n Stopping timer B");
  959. X#endif
  960. X   ciacr &= ~CIACRBF_START;
  961. X
  962. X   /*--- Wait until user lets go of button. */
  963. X
  964. X   LetGo();
  965. X
  966. X   return(0);
  967. X}
  968. X
  969. X#if DEBUG
  970. X/*-------------------- h e l p t x t . c ------------------------*/
  971. X/* This routine clears the help message area and writes a new    */
  972. X/* message into it.                                              */
  973. X/*---------------------------------------------------------------*/
  974. X
  975. Xint helptxt(msg1, msg2)
  976. X  char *msg1, *msg2;
  977. X{
  978. X
  979. X   /*--- Erase any old text that exists. */
  980. X
  981. X   SetAPen(WRPort, 0);
  982. X   RectFill(WRPort, 24, 163, 617, 188);
  983. X
  984. X   /*--- Write new text. */
  985. X
  986. X
  987. X   SetAPen(WRPort, 1);
  988. X   Move(WRPort, 25, 173);
  989. X   Text(WRPort, msg1, strlen(msg1));
  990. X   Move(WRPort, 25, 185);
  991. X   Text(WRPort, msg2, strlen(msg2));
  992. X
  993. X   return(0);
  994. X}
  995. X
  996. X/*---------------------- I R B u t t o n s O f f . c ---------------------*/
  997. X/* This routine unhighlights any currently selected control button.       */
  998. X/*------------------------------------------------------------------------*/
  999. X
  1000. Xint IRButtonOff(button)
  1001. X  int *button;  /* Button to turn off. */
  1002. X{
  1003. X   USHORT position;
  1004. X
  1005. X   if((*button >= 1) && (*button <= 20))
  1006. X   {
  1007. X      /*--- Remove currently selected gadget from list. */
  1008. X
  1009. X      position = RemoveGList(Window, IR[*button-1], 1L);
  1010. X
  1011. X      /*--- Unselect the gadget. */
  1012. X
  1013. X      IR[*button-1]->Flags &= (~SELECTED);
  1014. X
  1015. X      /*--- Put the gadget back into the same place in the list. */
  1016. X
  1017. X      AddGList(Window, IR[*button-1], (LONG)position, 1L, NULL);
  1018. X
  1019. X      /*--- Refresh gadgets on display. */
  1020. X
  1021. X      RefreshGList(IR[*button-1], Window, NULL, 1L);
  1022. X
  1023. X      /*--- Set currently selected gadget to none. */
  1024. X
  1025. X      *button = -1;
  1026. X   }
  1027. X
  1028. X   return(TRUE);
  1029. X}
  1030. X
  1031. X
  1032. X/*---------------------- I R B u t t o n s O n . c -----------------------*/
  1033. X/* This routine highlights the currently selected control button.         */
  1034. X/*------------------------------------------------------------------------*/
  1035. X
  1036. X
  1037. Xint IRButtonOn(button)
  1038. X  int button;  /* Button number to highlight. */
  1039. X{
  1040. X   USHORT position;
  1041. X
  1042. X   if((button >= 1) && (button <= 20))
  1043. X   {
  1044. X      /*--- Remove the selected gadget from list. */
  1045. X
  1046. X      position = RemoveGList(Window, IR[button-1], 1L);
  1047. X
  1048. X      /*--- Select the gadget. */
  1049. X
  1050. X      IR[button-1]->Flags |= SELECTED;
  1051. X
  1052. X      /*--- Put the gadget back into the same place in the list. */
  1053. X
  1054. X      AddGList(Window, IR[button-1], (LONG)position, 1L, NULL);
  1055. X
  1056. X      /*--- Refresh gadgets on display. */
  1057. X
  1058. X      RefreshGList(IR[button-1], Window, NULL, 1L);
  1059. X   }
  1060. X
  1061. X   return(TRUE);
  1062. X}
  1063. X
  1064. X/*------------------- I R B u t t o n L a b e l . c -------------------*/
  1065. X/* This routine relabels the selected button.                          */
  1066. X/*---------------------------------------------------------------------*/
  1067. X
  1068. Xint IRButtonLabel(buffer, button)
  1069. X  UBYTE *buffer;
  1070. X  int button;
  1071. X{
  1072. X   USHORT position;
  1073. X
  1074. X   if((button >= 1) && (button <= 20))
  1075. X   {
  1076. X      /*--- Remove the selected gadget from list. */
  1077. X
  1078. X      position = RemoveGList(Window, IR[button-1], 1L);
  1079. X
  1080. X      /*--- Change the label. */
  1081. X
  1082. X      strncpy(IR[button-1]->GadgetText->IText , (char *)buffer, 7);
  1083. X
  1084. X      /*--- Put the gadget back into the same place in the list. */
  1085. X
  1086. X      AddGList(Window, IR[button-1], (LONG)position, 1L, NULL);
  1087. X
  1088. X      /*--- Refresh gadgets on display. */
  1089. X
  1090. X      RefreshGList(IR[button-1], Window, NULL, 1L);
  1091. X   }
  1092. X
  1093. X   return(TRUE);
  1094. X}
  1095. X
  1096. X
  1097. X/*------------------ G e t P a t t e r n . c ---------------------*/
  1098. X/* This routine gets a signal sample from the IR receiver and     */
  1099. X/* then tries up to four times to verify it.                      */
  1100. X/*----------------------------------------------------------------*/
  1101. X
  1102. XGetPattern(button)
  1103. X  int button;  /* Currently selected control button. */
  1104. X{
  1105. X   int it, iz, is, try;
  1106. X   int diff[4], match, smallest;
  1107. X
  1108. X#if DBG
  1109. X   printf("\n\n **** Storing pattern %d ****", button);
  1110. X#endif
  1111. X
  1112. X   /*--- Get a sample. */
  1113. X
  1114. X   GetSample();
  1115. X
  1116. X   /*--- Plot data on screen. */
  1117. X
  1118. X   helptxt("Data received.", "");
  1119. X   /*DPattern(button, 1);*/
  1120. X   DisplayPattern(button, 0);
  1121. X
  1122. X#if DBG
  1123. X   printf("\n NSamples=%d", NSamples);
  1124. X#endif
  1125. X
  1126. X   /*--- Transfer data to storage. */
  1127. X
  1128. X#if DBG
  1129. X   printf("\n Xferring to pattern memory.");
  1130. X#endif
  1131. X   for(iz=0; iz<NSAMPLES; iz++)
  1132. X   {
  1133. X      pattern[button-1][iz] = zuffer[iz] & 0x01;
  1134. X#if DBG
  1135. X/*
  1136. X      if(pattern[button-1][iz] == 1)printf("|");
  1137. X      if(pattern[button-1][iz] == 0)printf("_");
  1138. X*/
  1139. X#endif
  1140. X   }
  1141. X
  1142. X   helptxt("Press the button again to verify the pattern.", "");
  1143. X
  1144. X   match = 0;
  1145. X   for(try=0; try<4; try++)  /* Try four times to get a match. */
  1146. X   {
  1147. X      GetSample(); /* Read IR signal again. */
  1148. X
  1149. X      helptxt("Data received.  Verifying match.", "");
  1150. X/*   DPattern(button, try+2);*/
  1151. X      DisplayPattern(button, 1);
  1152. X
  1153. X      /*--- Find number of cells that don't match. */
  1154. X
  1155. X      diff[try] = 0;
  1156. X      smallest = NSAMPLES+10;
  1157. X      for(iz=0; iz<NSAMPLES; iz++)
  1158. X      {
  1159. X         zuffer[iz] = zuffer[iz] & 0x01;
  1160. X         if(pattern[button-1][iz] != zuffer[iz])
  1161. X         {
  1162. X            diff[try]++;
  1163. X         }
  1164. X#if DBG
  1165. X/*
  1166. X         if(zuffer[iz] == 1)printf("|");
  1167. X         if(zuffer[iz] == 0)printf("_");
  1168. X*/
  1169. X#endif
  1170. X      }
  1171. X      if(diff[try] > TOLERENCE)
  1172. X      {
  1173. X#if DBG
  1174. X         printf("\n Samples do not match:%d  Please try again.",diff[try]);
  1175. X#endif
  1176. X         helptxt("Samples do not match.  Please press button again.", "");
  1177. X         if(diff[try] < smallest)
  1178. X         {
  1179. X            /*--- Store the best pattern so far. */
  1180. X            smallest = diff[try];
  1181. X            for(iz=0; iz<NSAMPLES; iz++)
  1182. X            {
  1183. X               pattern[button-1][iz] = zuffer[iz];
  1184. X            }
  1185. X         }
  1186. X      } else
  1187. X      {
  1188. X         match = 1;
  1189. X         break;
  1190. X      }
  1191. X   }
  1192. X   if(match == 0)
  1193. X   {
  1194. X      helptxt("Could not verify pattern.  Will use the best match of four tries.", "");
  1195. X#if DBG
  1196. X      printf("\n Could not verify pattern.  Will use the best match.");
  1197. X      printf("\n Try the analyzer to verify compatability of your unit.");
  1198. X#endif
  1199. X   } else
  1200. X   {
  1201. X      helptxt("Successful pattern match!", "");
  1202. X      DisplayPattern(button, 0);
  1203. X   }
  1204. X
  1205. X   return(TRUE);
  1206. X}
  1207. X
  1208. X
  1209. X/*-------------------- D i s p l a y P a t t e r n . c ------------------*/
  1210. X/* This routine draws the acquired pattern on the screen in the help     */
  1211. X/* message area.                                                         */
  1212. X/*-----------------------------------------------------------------------*/
  1213. X
  1214. Xint DisplayPattern(button, mode)
  1215. X  int button;  /* Currently selected control button. */
  1216. X  int mode;    /* 0 = draw pattern, 1 = draw difference. */
  1217. X{
  1218. X   int it;
  1219. X   SHORT row;
  1220. X
  1221. X   /*--- Any old text or pattern that existed should have been erased with */
  1222. X   /*--- a help message. */
  1223. X
  1224. X   /*--- Draw pattern. X range = 24 to 617 */
  1225. X
  1226. X   SetAPen(WRPort, 1);
  1227. X   row = 0;
  1228. X   for(it=0; it<NSAMPLES; it++)
  1229. X   {
  1230. X      if(mode == 0)
  1231. X      {
  1232. X         if((zuffer[it] & 0x01) == 1)
  1233. X         {
  1234. X            Move(WRPort, 26 + (SHORT)(it%590), 175 + row);
  1235. X            Draw(WRPort, 26 + (SHORT)(it%590), 175 + row);
  1236. X         }
  1237. X      } else
  1238. X      {
  1239. X         if((zuffer[it] & 0x01) != pattern[button-1][it])
  1240. X         {
  1241. X            Move(WRPort, 26 + (SHORT)(it%590), 175 + row);
  1242. X            Draw(WRPort, 26 + (SHORT)(it%590), 175 + row);
  1243. X         }
  1244. X      }
  1245. X
  1246. X      /*--- Space the data in rows. */
  1247. X
  1248. X      if((it%590 == 0) &&(it != 0))row = row + 2;
  1249. X   }
  1250. X#if DBG
  1251. X   printf("\n Drew the pattern.");
  1252. X#endif
  1253. X
  1254. X   return(TRUE);
  1255. X}
  1256. X
  1257. X
  1258. X
  1259. Xint DPattern(button, mode)
  1260. X  int button;  /* Currently selected control button. */
  1261. X  int mode;    /* 0 = draw pattern, 1 = draw difference. */
  1262. X{
  1263. X   int it;
  1264. X   SHORT row;
  1265. X
  1266. X   /*--- Any old text or pattern that existed should have been erased with */
  1267. X   /*--- a help message. */
  1268. X
  1269. X   /*--- Draw pattern. X range = 24 to 617 */
  1270. X
  1271. X   SetAPen(WRPort, 1);
  1272. X   row = 0;
  1273. X   for(it=0; it<NSAMPLES; it++)
  1274. X   {
  1275. X      if((zuffer[it] & 0x01) == 1)
  1276. X      {
  1277. X         Move(WRPort, 26 + (SHORT)(it%590), 175 + row - mode*20);
  1278. X         Draw(WRPort, 26 + (SHORT)(it%590), 175 + row - mode*20);
  1279. X      }
  1280. X
  1281. X      /*--- Space the data in rows. */
  1282. X
  1283. X      if((it%590 == 0) &&(it != 0))row = row + 2;
  1284. X   }
  1285. X
  1286. X   return(TRUE);
  1287. X}
  1288. X#endif /*DEBUG*/
  1289. X
  1290. X/*-------------------- f i n d _ m a t c h . c ----------------------*/
  1291. X/*  Find pattern which is the closest match to the one just read in. */
  1292. X/*-------------------------------------------------------------------*/
  1293. X
  1294. Xint find_match()
  1295. X{
  1296. X   int match, it, smallest;
  1297. X   int diff, pat;
  1298. X
  1299. X#if DBG
  1300. X   printf("\n Matching patterns...");
  1301. X#endif
  1302. X
  1303. X   /*--- Mask of bit of interest in zuffer. */
  1304. X
  1305. X   for(it=0; it<NSAMPLES; it++)zuffer[it] = zuffer[it] & 0x01;
  1306. X
  1307. X   /*--- Compare data to stored patterns. */
  1308. X
  1309. X   match = -1;
  1310. X   smallest = NSAMPLES+10;
  1311. X   for(pat=0; pat<20; pat++)  /* Step through all stored patterns. */
  1312. X   {
  1313. X      if(active[pat+1])  /* Only examine active patterns to save time. */
  1314. X      {
  1315. X         diff = 0;
  1316. X         for(it=0; it<NSAMPLES; it++)
  1317. X         {
  1318. X            if(pattern[pat][it] != zuffer[it])diff++;
  1319. X         }
  1320. X      }
  1321. X      if(diff < smallest)
  1322. X      {
  1323. X         smallest = diff;
  1324. X         match = pat;
  1325. X      }
  1326. X#if DBG
  1327. X      printf("\n diff(%d)=%d", pat, diff);
  1328. X#endif
  1329. X   }
  1330. X
  1331. X#if DBG
  1332. X   printf("\n Best match is pattern %d", match);
  1333. X   if(match == -1)
  1334. X   {
  1335. X      printf("\n No match for pattern!");
  1336. X   }
  1337. X#endif
  1338. X
  1339. X   return(match);
  1340. X}
  1341. END_OF_FILE
  1342. if test 27153 -ne `wc -c <'irc.c'`; then
  1343.     echo shar: \"'irc.c'\" unpacked with wrong size!
  1344. fi
  1345. # end of 'irc.c'
  1346. fi
  1347. if test -f 'irc.h' -a "${1}" != "-c" ; then 
  1348.   echo shar: Will not clobber existing file \"'irc.h'\"
  1349. else
  1350. echo shar: Extracting \"'irc.h'\" \(948 characters\)
  1351. sed "s/^X//" >'irc.h' <<'END_OF_FILE'
  1352. X/*------------------------------ i r c . h ---------------------------------*/
  1353. X/* Include files and variable definitions for irc.c                         */
  1354. X/*--------------------------------------------------------------------------*/
  1355. X
  1356. X#include "stdio.h"
  1357. X#include "stdlib.h"   /* Contains alloc() and free() definitions. */
  1358. X#include "workbench/workbench.h"
  1359. X#define INTUITIONPRIVATE   /* Allow access to private parts of IntuitionBase. */
  1360. X#include "intuition/intuitionbase.h"
  1361. X#include "graphics/gfxbase.h"
  1362. X#include "graphics/rastport.h"
  1363. X#include "proto/all.h"  /* Do I really need this? */
  1364. X#include "exec/execbase.h"
  1365. X#include "exec/exec.h"
  1366. X#include <exec/types.h>
  1367. X#include <exec/tasks.h>
  1368. X#include <exec/interrupts.h>
  1369. X#include <exec/memory.h>
  1370. X#include "hardware/intbits.h"
  1371. X#include "hardware/custom.h"
  1372. X#include <hardware/cia.h>
  1373. X#include <resources/cia.h>
  1374. X#include "workbench/startup.h"
  1375. X#include "string.h"
  1376. X#include "signal.h"
  1377. X#include "VERSION.h"
  1378. X
  1379. END_OF_FILE
  1380. if test 948 -ne `wc -c <'irc.h'`; then
  1381.     echo shar: \"'irc.h'\" unpacked with wrong size!
  1382. fi
  1383. # end of 'irc.h'
  1384. fi
  1385. if test -f 'ircserver.asm' -a "${1}" != "-c" ; then 
  1386.   echo shar: Will not clobber existing file \"'ircserver.asm'\"
  1387. else
  1388. echo shar: Extracting \"'ircserver.asm'\" \(4686 characters\)
  1389. sed "s/^X//" >'ircserver.asm' <<'END_OF_FILE'
  1390. X;
  1391. X;  ircserver.asm
  1392. X;
  1393. X;  This Lattice V5.04 assembly language routine gets added to the
  1394. X;  level 2 interrupt server chain to deal with INT2 interrupts
  1395. X;  caused by bringing the ACK pin on the parallel port low.
  1396. X;
  1397. X;
  1398. X;  NOTE: Lattice asm doesn't like: move.l _irc, a1
  1399. X;          and DOES like: move.l _irc,a1
  1400. X;          Only difference is the space before "a1".
  1401. X; Also, calling an external Lattice C routine from assembly must be
  1402. X; done after the Enable(), Permit().  (Would probably work before
  1403. X; the Forbid(), Disable() too.)
  1404. X; To pass a variable which is a pointer to a C function use:
  1405. X;
  1406. X;          [struct Interrupt *SoftInterrupt; Cause(SoftInterrupt);]
  1407. X;
  1408. X;        move.l     _SoftInterrupt,a1   ; Put address of Interrupt structure
  1409. X;        move.l     a1,-(a7)            ; onto stack.
  1410. X;        JSR       _Cause
  1411. X;        ADDQ      #4,A7                ; Fix the stack pointer.
  1412. X;
  1413. X; To pass a variable which is NOT a pointer AS a pointer to a C function use:
  1414. X;
  1415. X;          [struct Interrupt SoftInterrupt; Cause(&SoftInterrupt);]
  1416. X;
  1417. X;        LEA       _SoftInterrupt,A1
  1418. X;        MOVE.L    A1,-(A7)
  1419. X;        JSR       _Cause
  1420. X;        ADDQ      #4,A7                ; Fix the stack pointer.
  1421. X;
  1422. X;
  1423. X;
  1424. X        csect data,1,,2,2
  1425. X        xref _LVOSignal
  1426. X
  1427. X        csect text
  1428. X
  1429. X    xdef _ircserver
  1430. X
  1431. X        xref _ciab
  1432. X        xref _SoftInterrupt
  1433. X        xref _thisTask
  1434. X        xref _TimerSigMask
  1435. X        xref _buffer
  1436. X        xref _NSamples
  1437. X
  1438. X        xref _Forbid
  1439. X        xref _Disable
  1440. X        xref _Enable
  1441. X        xref _Permit
  1442. X
  1443. X        xref _custom
  1444. X
  1445. Xdata1             equ   $bfe101
  1446. Xdir1              equ   $bfe301
  1447. X
  1448. X_ircserver
  1449. X;
  1450. X; Save registers on stack.
  1451. X;
  1452. X        MOVEM.L A2-A6/D2-D7,-(SP)  ;  Push Registers 
  1453. X;
  1454. X; Disable interrupts and tasking.
  1455. X;
  1456. X        JSR       _Forbid  ; RKM says this is a no-no but don't work without it.
  1457. X        JSR       _Disable
  1458. X; Machine is MINE now until I let it go!
  1459. X;
  1460. X;
  1461. X;  Read from parallel port to see if IR hardware triggered this interrupt.
  1462. X;  If not then let the server chain continue without further ado.
  1463. X;
  1464. X;
  1465. X; Set up parallel port for reading.
  1466. X;
  1467. X      move.b   #0,dir1           * all lines read
  1468. X      move.b   #0,data1
  1469. X      move.b   data1,d0       ; Move byte from parallel port to register.
  1470. X      andi.b   #$01,d0        ; Mask off bit 0.
  1471. X      beq      proceed        ; If bit is one, then proceed to capture data.
  1472. X
  1473. X      JSR       _Enable
  1474. X      JSR       _Permit  ; RKM says this is a no-no but don't work without it.
  1475. X      MOVEM.L (SP)+,A2-A6/D2-D7  ;  Pop Registers
  1476. X      MOVEQ     #$00,D0          ; Continue the server chain.
  1477. X      RTS
  1478. X;
  1479. X; Disable the ACK interrupt until after processing is done.
  1480. X; (Is re-enabled in irc.c)
  1481. X; Hex 10 = 00010000 Should disable the 8520 FLAG interrupt.
  1482. X;
  1483. Xproceed:   move.b  #$10,$BFED01
  1484. X;
  1485. X; Turn off the display so that DMA access for screen update doesn't
  1486. X; steal cycles from the 68000 processor.
  1487. X;  $0100 = clear BPLEN bit; custom+$96 = dmacon register
  1488. X;
  1489. X           move.w #$100,$96+_custom
  1490. X;
  1491. X; Start timer B.
  1492. X;
  1493. X        lea.l _ciab,a1      ; Get address of ciab
  1494. X        adda.l  #$F00,a1    ; Add offset for ciacrb register.
  1495. X        or.b #$01,(a1)      ; $01 = CIACRBF_START ---> Starts timer b!
  1496. X;
  1497. X; Read data from parallel port until buffer is full.
  1498. X;
  1499. Xhold: move.b    $bfdd00,d0  ; Read 8520 IRC register to get/reset interrupt bit
  1500. X      andi.l    #$02,d0     ; Mask off timer B interrupt bit.
  1501. X      beq       hold        ; Loop till get an interrupt.
  1502. X;
  1503. X; Read a byte from 8250-A (parallel port)  The data direction registers are
  1504. X; set up in SoftHandler.
  1505. X;
  1506. X      movea.l  _buffer,a1        ; a1 now holds buffer location
  1507. X      move.b   data1,(a1)+       ; Move byte from parallel port to buffer.
  1508. X      move.l   a1,_buffer        ; Update pointer to buffer.
  1509. X      subq.l   #$1,_NSamples     ; 8
  1510. X      bne      hold              ; Go wait for next timeout if buffer not full.
  1511. X
  1512. X      move.b #$02,$BFDD00   ; Disable timer B interrupts.
  1513. X      move.b    $bfdd00,d0  ; Read 8520 IRC register to reset interrupt bit.
  1514. X;
  1515. X; Turn on the display (enable bitplane DMA).
  1516. X;  $8100 = set BPLEN bit; custom+$96 = dmacon register
  1517. X;
  1518. X           move.w #$8100,_custom+$96
  1519. X;
  1520. X; Enable interrupts and tasking.
  1521. X;
  1522. X        JSR       _Enable
  1523. X        JSR       _Permit  ; RKM says this is a no-no but don't work without it.
  1524. X;
  1525. X; Signal main task to wake up.  Data is ready!
  1526. X;
  1527. X      move.l    _TimerSigMask,d0     ; Set up data in registers.
  1528. X      movea.l    _thisTask,a1
  1529. X      movea.l   $4,a6
  1530. X      jsr       _LVOSignal(a6)       ; Send signal (see note above.)
  1531. X;
  1532. X;
  1533. X; Clean up, restore registers and return.
  1534. X;
  1535. X        MOVEM.L (SP)+,A2-A6/D2-D7  ;  Pop Registers
  1536. X        MOVEQ     #$00,D0          ; Continue the server chain.
  1537. X        RTS
  1538. X
  1539. X        END
  1540. END_OF_FILE
  1541. if test 4686 -ne `wc -c <'ircserver.asm'`; then
  1542.     echo shar: \"'ircserver.asm'\" unpacked with wrong size!
  1543. fi
  1544. # end of 'ircserver.asm'
  1545. fi
  1546. if test -f 'linkirc' -a "${1}" != "-c" ; then 
  1547.   echo shar: Will not clobber existing file \"'linkirc'\"
  1548. else
  1549. echo shar: Extracting \"'linkirc'\" \(100 characters\)
  1550. sed "s/^X//" >'linkirc' <<'END_OF_FILE'
  1551. XFROM LIB:c.o+irc.o+ircserver.o+LetGo.o+BackGround.o
  1552. XTO irc
  1553. XLIBRARY LIB:lc.lib+LIB:amiga.lib
  1554. XNODEBUG
  1555. END_OF_FILE
  1556. if test 100 -ne `wc -c <'linkirc'`; then
  1557.     echo shar: \"'linkirc'\" unpacked with wrong size!
  1558. fi
  1559. # end of 'linkirc'
  1560. fi
  1561. if test -f 'readme' -a "${1}" != "-c" ; then 
  1562.   echo shar: Will not clobber existing file \"'readme'\"
  1563. else
  1564. echo shar: Extracting \"'readme'\" \(1922 characters\)
  1565. sed "s/^X//" >'readme' <<'END_OF_FILE'
  1566. XThis code is an uncompleted version of an IR remote controlled AREXX
  1567. Xutility.  It is uncompleted because no one wants to pay me to finish
  1568. Xit (great sadness...)  I have placed it in the public domain as an example
  1569. Xof how to read an IR remote control signal using the parallel port.
  1570. XI take no responsibility for the correctness or usability of this
  1571. Xcode.  I would apologize for the funkyness of it but I'm giving
  1572. Xit to you for free so just be glad I'm reasonably free with comments
  1573. Xas to what's going on in it.
  1574. XThe code runs as it is on an Amiga 1000 with 1.5M of RAM (I suspect it
  1575. Xwill run in 512K also) when compiled using Lattice's V5.04 C compiler
  1576. Xand asm assembler.  I've only run it under V1.2 of the operating
  1577. Xsystem so I don't know how it will work under V1.3 and higher.
  1578. XI've pulled out all the AREXX specific code so that you don't have
  1579. Xto have AREXX to compile or run it.  The file Schematic.ilbm contains
  1580. Xa simple electronics schematic for hooking a Radio Shack IR receiver
  1581. Xto the parallel port on an A1000.  NOTE that if you have an Amiga
  1582. Xother than an A1000 you must change the +5Vdc and gnd connections and
  1583. Xuse a male connector instead of a female.  I think the connections
  1584. Xfor other machines is pin 14 = +5Vdc and pin 25 = gnd but don't
  1585. Xtrust my memory---verify it!
  1586. XTo try the code, plug in the hardware with the computer off, boot
  1587. Xthe computer, run the code, click on the LEARN button, then click
  1588. Xon one of the 20 buttons in the upper right, enter a short name
  1589. Xin the text requestor (next to the AREXX button) hit return and
  1590. Xthen press a button on your IR remote (you'll have press it twice
  1591. Xso that it can be verified.)  The pattern of the digitized data
  1592. Xwill be drawn on the screen followed by the pattern of the
  1593. Xdifferences between the first and second samples.  The code prompts
  1594. Xyou for most of this.  The rest of it I'll let you figure out for
  1595. Xyourselves.  Have fun!
  1596. X
  1597. Xron@vicorp.com or uunet!vicorp!ron
  1598. END_OF_FILE
  1599. if test 1922 -ne `wc -c <'readme'`; then
  1600.     echo shar: \"'readme'\" unpacked with wrong size!
  1601. fi
  1602. # end of 'readme'
  1603. fi
  1604. if test -f 'tmp' -a "${1}" != "-c" ; then 
  1605.   echo shar: Will not clobber existing file \"'tmp'\"
  1606. else
  1607. echo shar: Extracting \"'tmp'\" \(124 characters\)
  1608. sed "s/^X//" >'tmp' <<'END_OF_FILE'
  1609. X;
  1610. Xasm ircserver.asm
  1611. Xasm LetGo.asm
  1612. X;
  1613. Xlc -cc -ff -adb irc
  1614. Xlc -cc -ff -adb BackGround
  1615. X;
  1616. X; Link with BLINK
  1617. X;
  1618. Xblink with linkirc
  1619. END_OF_FILE
  1620. if test 124 -ne `wc -c <'tmp'`; then
  1621.     echo shar: \"'tmp'\" unpacked with wrong size!
  1622. fi
  1623. # end of 'tmp'
  1624. fi
  1625. echo shar: End of archive 1 \(of 5\).
  1626. cp /dev/null ark1isdone
  1627. MISSING=""
  1628. for I in 1 2 3 4 5 ; do
  1629.     if test ! -f ark${I}isdone ; then
  1630.     MISSING="${MISSING} ${I}"
  1631.     fi
  1632. done
  1633. if test "${MISSING}" = "" ; then
  1634.     echo You have unpacked all 5 archives.
  1635.     rm -f ark[1-9]isdone
  1636. else
  1637.     echo You still need to unpack the following archives:
  1638.     echo "        " ${MISSING}
  1639. fi
  1640. ##  End of shell archive.
  1641. exit 0
  1642. -- 
  1643. Mail submissions (sources or binaries) to <amiga@uunet.uu.net>.
  1644. Mail comments to the moderator at <amiga-request@uunet.uu.net>.
  1645. Post requests for sources, and general discussion to comp.sys.amiga.misc.
  1646.